//
//  EditAddressCell.m
//  Yanwei
//
//  Created by 刘文 on 17/5/4.
//  Copyright © 2017年 DCloud. All rights reserved.
//

#import "EditAddressCell.h"

@interface EditAddressCell ()

@property (strong, nonatomic) UIView * bottomLineView;

@end

@implementation EditAddressCell
@synthesize textField;

- (void)setPlaceholder:(NSString *)placeholder {
    _placeholder = placeholder;
    self.textField.placeholder = placeholder;
}

- (void)setLineHedden:(BOOL)lineHedden {
    _lineHedden = lineHedden;
    self.bottomLineView.hidden = lineHedden;
}

- (UITextField *)textField {
    if (!textField) {
        textField = [UITextField new];
        textField.adjustsFontSizeToFitWidth = YES;
        textField.minimumFontSize = 8;
        textField.font = APPFONT(15);
        [textField setValue:Color140 forKeyPath:@"_placeholderLabel.textColor"];
        [self.contentView addSubview:textField];
        [textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView);
            make.top.equalTo(self.contentView);
            make.right.equalTo(self.contentView);
            make.bottom.equalTo(self.contentView).with.offset(-1);
        }];
        
        textField.leftViewMode = UITextFieldViewModeAlways;
        textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 18, 0)];
    }
    return textField;
}

- (UIView *)bottomLineView {
    if (!_bottomLineView) {
        _bottomLineView = [UIView new];
        _bottomLineView.backgroundColor = Color217;
        [self.contentView addSubview:_bottomLineView];
        [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).with.offset(18);
            make.right.equalTo(self.contentView);
            make.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(0.5);
        }];
    }
    return _bottomLineView;
}

@end
